package cn.itcast.server.service;

import java.util.Iterator;
import java.util.ServiceLoader;

public class ServiceFactory {

    public static <T> T getService(Class<T> clazz){
        ServiceLoader<T> load = ServiceLoader.load(clazz);
        Iterator<T> iterator = load.iterator();
        return iterator.next();
    }




    public static void main(String[] args) {
        HelloService service = getService(HelloService.class);
        String test = service.sayHello("test");
        System.out.println(test);
    }
}
